﻿using DevExpress.Data;
using DevExpress.XtraGrid;
using DXApplicationTangche.UC.面料审核.Service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.面料审核
{
    public partial class Form成衣同款库存 : DevExpress.XtraEditors.XtraForm
    {
        private List<GarmentStockDTO> garmentStockDTOs = new List<GarmentStockDTO>();
        public Form成衣同款库存()
        {
            InitializeComponent();
        }
        public Form成衣同款库存(String barcode, String styleNameCn, String fabricCode, List<GarmentStockDTO> garmentStockDTOs)
        {
            InitializeComponent();
            this.textBox款式.Text = styleNameCn;
            this.textBox面料号.Text = fabricCode;
            this.gridControl库存.DataSource = garmentStockDTOs;
            this.gridView1.ExpandAllGroups();
            this.gridView1.RefreshData();
            this.gridView1.GroupSummary.AddRange(new GridSummaryItem[] { new GridGroupSummaryItem(SummaryItemType.Count, "barcode", null, "(数量总计= {0})"), });
            this.gridView1.GroupSummary.AddRange(new GridSummaryItem[] { new GridGroupSummaryItem(SummaryItemType.Sum, "price", null, "(金额总计= {0})"), });
            this.label库存.Text = "库存总数量：" + garmentStockDTOs.Count();
        }

        private void gridView1_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
        {
            if (e.Column.Name.Equals("gridColumn尺寸"))
            {
                if (!String.IsNullOrWhiteSpace(e.DisplayText))
                {
                    try { e.DisplayText = e.DisplayText.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
                }
                else
                {
                    e.DisplayText = "样衣无尺寸定义";
                }
            }
        }
    }
}
